Txt2Site User Manual
System Overview
Txt2Site creates websites. Pages are created using a HTML template. The layout of pages can be beautified by stylesheets.
The content part of a page is defined by a text file. These text files are located in the content directory of the application. The directory structure of the content directory reflects the page structure of the website.
If you provide Txt2Site with:
Then Txt2Site provides you with a website:
All application data is located in one parent directory, the root directory of the application. The configuration file is always located in the root directory. The configuration file tells Txt2Site the location of files such as content files and templates, and where to put the new website. If not specified in the config file, Txt2Site uses a default directory structure.
Default directory structure The default directory structure is drawn next to with a root directory called my_demo. The default configuration is declared as: - content_dir=content - include_dir=include - template_dir=templates - target_dir=site/target - style_dir= The directories are declared relative to the application root. See the examples section for some alternative directory structures. |
![]() |
Txt2Site provides two main scripts:
The first script creates an environment in the working directory with a default directory structure. It also creates a content file with some content to test. The command to execute this script is:
$ txt2site -n my_demo
Here my_demo is the name of the root directory. As you expect the root directory is created in the current working directory. It creates a new demo application with a config file called my_demo.conf.
The base color of the demo website is by default green. If you insert one of the colors red, green, yellow, grey or blue in the name of the application, then this color is the base color of the website.
The second script creates/updates the website based on the content files. After you update the content files you can execute it again. The command to execute this script is:
$ txt2site -g my_demo/my_demo.conf
The command with option -g (generate) has the config file as argument. The path of the config file is relative to the working directory. If the config file does not exist, the command finishes with an error message.
The next drawing shows you broadly how Txt2Site processes data when creating a website.
![]() |
In terms of the default application structure the following steps are executed to generate a website:
Variables are defined and get a value (string) in three ways:
A variable can be called everywhere in a content section, template file or stylesheet by typing:
${variable-name}
Using a variable in this manner, Txt2Site will substitute its value when generating a new site.
Functions are defined by the system. While variables has a string as value, functions can have multiple lines as output. These lines can be user defined or system defined. For example a user defined output is generated by the function html_content_div which outputs a content section to be included in a page. A system defined output is generated by the function html_mainmenu_div which outputs a navigation menu.
The result of a function can be inserted everywhere in a content section or template file by typing:
$(function-name)
In case of two arguments, the syntax is: $(function-name arg1 arg2).
Once defined, variables and functions can be used in content sections, template files and stylesheets.
The process of replacing all variables and functions with its value is called evaluation.
For each generated page there are two evaluation steps:
The evaluation of the template file is always performed, the second evaluation can be prevented if you want by giving the second argument of these functions the value "noeval".
Benefits of not evaluating variables and functions (if any) is, you can freely use the dollar symbol in your text and it gives you a slightly better performance. If evaluation must be performed, you had to hide the dollar symbol where you do not want it to evaluate by Txt2Site.
Once the website is generated, a last evaluation step is performed, where variables in the stylesheets are replaced by their value. See stylesheet variables in the section File Types.
Prevent evaluation of ${variable_name} or $(function_name) by putting the backslash escape character \ before the dollar symbol.
See the Tutorial chapter for examples how to maintain your website.